package com.lm.statemachine.controller;

import com.lm.statemachine.service.OrderService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Resource
    private OrderService orderService;

    @GetMapping("/pay/{id}")
    public String payOrder(@PathVariable("id") Integer id) {
        orderService.payOrder(id);
        return "Order paid ";
    }

    @GetMapping("/ship/{id}")
    public String shipOrder(@PathVariable("id") Integer id) {
        orderService.shipOrder(id);
        return "Order shipped ";
    }

    @GetMapping("/complete/{id}")
    public String completeOrder(@PathVariable("id") Integer id) {
        orderService.completeOrder(id);
        return "Order completed ";
    }
}
